/* GUI CONVERTED from repkiq.p (converter v1.76) Tue Aug 27 17:16:58 2002 */
/* repkiq.p - REPETITIVE PICKLIST INQUIRY                               */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.7.1.8 $                                                      */
/*V8:ConvertMode=Report                                        */
/* REVISION: 7.3      LAST MODIFIED: 09/06/92   BY: emb *G071*          */
/* Revision: 7.3        Last edit:   11/19/92   By: jcd *G339*          */
/*                                   08/27/94   BY: bcm *GL62*          */
/* Revision: 7.3        Last edit:   11/22/94   By: qzl *GO59*          */
/* Revision: 8.6      LAST MODIFIED: 10/11/97   By: bvm *K0S4*          */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb              */
/* $Revision: 1.7.1.8 $      BY: Dave Caveney DATE: 08/21/02 ECO: *P0G8* */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE          */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

define variable nbr as character format "x(10)" label "Picklist".
define variable ladnbr like nbr.
define variable prod_site like lad_site.
define variable seq as integer format ">>>" label "Sequence" column-label "Seq".

define variable qopen like lad_qty_all.
define variable qty_pick like lad_qty_pick.
define shared variable global_recid as recid.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
space(1)
   prod_site
   nbr seq
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

nbr = "".
prod_site = global_site.

display prod_site nbr with frame a.

{wbrp01.i}

/* DISPLAY */
mainloop:
repeat:

   view frame a.

   do on error undo, retry with frame a:

      global_recid = ?.

      if c-application-mode <> 'web' then
      set prod_site nbr seq
         with frame a
      editing:

         if frame-field = "prod_site" then do:
            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp05.i lad_det lad_det
               "lad_dataset = ""rps_det"""
               substring(lad_nbr,1,8) prod_site}
            if recno <> ? then
            display substring(lad_nbr,1,8) @ prod_site
            with frame a.
            recno = ?.
         end.
         else if frame-field = "nbr" then do:
            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp05.i lad_det lad_det
               "lad_dataset = ""rps_det""
                 and lad_nbr begins string(input prod_site,""x(8)"") "
               substring(lad_nbr,1,18)
               "string(input prod_site,""x(8)"")
                 + string(input nbr,""x(10)"") "}
            if global_recid <> ? then find lad_det where recid(lad_det) =
               global_recid no-lock no-error.

            if recno <> ? or (global_recid <> ? and available lad_det) then
               display substring(lad_nbr,9) @ nbr
               substring(lad_nbr,1,8) @ prod_site
               substring(lad_nbr,19) format "x(3)" @ seq
            with frame a.
            recno = ?.
            global_recid = ?.
         end.
         else if frame-field = "seq" then do:
            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp05.i lad_det lad_det
               "lad_dataset = ""rps_det""
                 and lad_nbr begins string(input prod_site,""x(8)"")
                 + string(input nbr,""x(10)"") "
               lad_nbr "string(input prod_site,""x(8)"")
                 + string(input nbr,""x(10)"")
                 + string(input seq,""999"") "}
            if recno <> ? then
               display substring(lad_nbr,19)  format "x(3)" @ seq with frame a.
            recno = ?.
         end.
         else do:
            status input.
            readkey.
            apply lastkey.
         end.
      end.

      {wbrp06.i &command = set &fields = "  prod_site nbr seq" &frm = "a"}

      if (c-application-mode <> 'web') or
         (c-application-mode = 'web' and
         (c-web-request begins 'data')) then do:

         if not
            can-find(si_mstr where si_site = prod_site)
         then do:
            {pxmsg.i &MSGNUM=708 &ERRORLEVEL=2}
         end.
         if not
            can-find(first lad_det where lad_dataset = "rps_det"
            and lad_nbr begins prod_site)
         then do:
            {pxmsg.i &MSGNUM=1156 &ERRORLEVEL=3}

            if c-application-mode = 'web' then return.
            else next-prompt prod_site.
            undo, retry.
         end.
         if nbr > "" then
         if not
            can-find(first lad_det where lad_dataset = "rps_det"
            and lad_nbr begins  string(prod_site,"x(8)") + nbr)
         then do:
            {pxmsg.i &MSGNUM=1156 &ERRORLEVEL=3}

            if c-application-mode = 'web' then return.
            else next-prompt nbr.
            undo, retry.
         end.

         if seq <> 0 then
         if not
            can-find(first lad_det where lad_dataset = "rps_det"
            and lad_nbr = string(prod_site,"x(8)") + string(nbr,"x(10)")
            + string(seq,"999"))
         then do:
            {pxmsg.i &MSGNUM=1156 &ERRORLEVEL=3}

            if c-application-mode = 'web' then return.
            else next-prompt seq.
            undo, retry.
         end.

         hide frame c.

      end.

      /* OUTPUT DESTINATION SELECTION */
      {gpselout.i &printType = "terminal"
                  &printWidth = 80
                  &pagedFlag = " "
                  &stream = " "
                  &appendToFile = " "
                  &streamedOutputToTerminal = " "
                  &withBatchOption = "no"
                  &displayStatementType = 1
                  &withCancelMessage = "yes"
                  &pageBottomMargin = 6
                  &withEmail = "yes"
                  &withWinprint = "yes"
                  &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.


   end.

   ladnbr = string(prod_site,"x(8)") + nbr.
   if seq <> 0 then ladnbr = string(ladnbr,"x(18)") + string(seq,"999").

   for each lad_det no-lock
      where lad_dataset = "rps_det"
      and lad_nbr begins prod_site
      and lad_nbr matches if nbr > "" then ladnbr + "*"
      else string(prod_site,"x(8)") + "*"
      break by lad_dataset by lad_nbr by lad_line by lad_part by lad_site
      with frame c width 80 no-attr-space down:
      /* SET EXTERNAL LABELS */
      setFrameLabels(frame c:handle).
      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


      if first-of(lad_part) then do:
         assign qopen = 0
                qty_pick = 0.
      end.
      assign qopen = qopen + lad_qty_all + lad_qty_pick
             qty_pick = qty_pick + lad_qty_pick.

      if not last-of (lad_part) then next.

      find pt_mstr no-lock where pt_part = lad_part no-error.

      if frame-down(c) <> 0 then do with frame c:
         if frame-down(c) - frame-line(c) < 2
            and available pt_mstr and pt_desc1 > "" and pt_desc2 > ""
            then down frame-down(c) - frame-line(c) + 1 with frame c.
         else
      if frame-down(c) - frame-line(c) < 1
            and available pt_mstr and (pt_desc1 > "" or pt_desc2 > "")
            then down frame-down(c) - frame-line(c) + 1 with frame c.
      end.

      display
         substring(lad_nbr,9) @ nbr
         substring(lad_nbr,19) format "x(3)" @ seq
         lad_line   @ op_wkctr
         lad_part format "x(27)"
         qopen format "->>>>>>>9.9<<<<<<<" label "Qty Open"
         qty_pick format "->>>>>>>9.9<<<<<<<" label "Qty Picked"
         pt_um when (available pt_mstr)
      with frame c STREAM-IO /*GUI*/ .

      if available pt_mstr and pt_desc1 > "" then do with frame c:
         down 1.
         display "   " + pt_desc1 @ lad_part WITH STREAM-IO /*GUI*/ .
      end.

      if available pt_mstr and pt_desc2 > "" then do with frame c:
         down 1.
         display "   " + pt_desc2 @ lad_part WITH STREAM-IO /*GUI*/ .
      end.
   end.

   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

   {pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}

end.

{wbrp04.i &frame-spec = a}
